package com.xiaobao.coalproperty.module.user.view;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.xiaobao.coalproperty.App;
import com.xiaobao.coalproperty.MainActivity;
import com.xiaobao.coalproperty.R;
import com.xiaobao.coalproperty.module.login.view.LoginActivity;
import com.xiaobao.coalproperty.other.base.BaseActivity;
import com.xiaobao.coalproperty.other.util.ActivityCollector;
import com.xiaobao.coalproperty.other.util.DialogUtils;
import com.xiaobao.coalproperty.other.util.UserHelperUtils;

public class UserSetActivity extends BaseActivity {

    private static final String TAG = "UserSetActivity";

    @Override
    protected int getContentView() {
        return R.layout.activity_user_set;
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setLeftClickFinish();
        setTitle("设置");
    }

    public void onUserSetWithdrawDataClick(View view) {
        startActivity(new Intent(this, WithdrawDataActivity.class));
    }

    public void onUserSetRePhoneClick(View view) {
        Intent intent = new Intent(this, ReBindingPhoneActivity.class);
        intent.setAction("type");
        intent.putExtra("type", 0);
        startActivity(intent);
    }

    public void onUserSetPwdManagerClick(View view) {
        startActivity(new Intent(this, PasswordManagerActivity.class));
    }

    public void onUserSetRePwdClick(View view) {
        startActivity(new Intent(this, RePasswordActivity.class));
    }

    public void onUserSetOut(View view) {
        DialogUtils.createConfirmDialog(this, "提示", "确定要退出登录吗？", "确定", "取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                UserHelperUtils.getInstance().clearUser();
               for (Activity activity: ActivityCollector.activities){
                   if(activity instanceof MainActivity){
                       activity.finish();
                   }
               }
               startActivity(new Intent(UserSetActivity.this, LoginActivity.class));
                for (Activity activity: ActivityCollector.activities){
                    Log.e(TAG, "onClick: "+activity.getLocalClassName() );
                }
               finish();
            }
        }, null, -1).show();
    }
}
